package cn.com.ddapp.ddm.fragment.base.commidcontext;

import android.os.Bundle;
import android.text.TextUtils;
import android.view.View;
import android.widget.FrameLayout;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.ListView;
import android.widget.TextView;

import com.bumptech.glide.Glide;

import butterknife.BindView;
import cn.com.ddapp.ddm.AppConfig;
import cn.com.ddapp.ddm.R;
import cn.com.ddapp.ddm.api.OKUtilAPI;
import cn.com.ddapp.ddm.base.BaseApplication;
import cn.com.ddapp.ddm.fragment.base.BaseFragment;
import cn.com.ddapp.ddm.util.TDevice;
import cn.com.ddapp.ddm.widget.video.CommonVideoView;

/**
 * Created by Administrator on 2016/8/22 0022.//商品详情页面，效果视图
 */
public class EffectContextFragment extends BaseFragment {
    @BindView(R.id.videoList)
    ListView videoList;
    @BindView(R.id.videogood)
    FrameLayout videogood;
    @BindView(R.id.videoView)
    CommonVideoView videoView;
    @BindView(R.id.video_tip)
    TextView video_tip;
    @BindView(R.id.videoImage)
    ImageView videoImage;

    @Override
    protected String getFragmentTag() {
        return null;
    }

    @Override
    protected void initData() {

    }

    @Override
    protected void initView(View view, Bundle savedInstanceState) {
//        VideoAdapter videoAdapter=new VideoAdapter(getContext());
//        videoList.setAdapter(videoAdapter);
//        videoView.start("http://baobab.wdjcdn.com/145076769089714.mp4");
        String vUrl=OKUtilAPI.imgBaseUrl+ AppConfig.GOOD_VIDEO;
        if(TextUtils.isEmpty(AppConfig.GOOD_VIDEO)){
            video_tip.setVisibility(View.VISIBLE);
            videoImage.setVisibility(View.GONE);
            videoView.setVisibility(View.GONE);
        }else{
            video_tip.setVisibility(View.GONE);
            videoImage.setVisibility(View.GONE);
            if(TDevice.isTablet(BaseApplication.getIntstance())){
//                int width=(int)TDevice.getScreenWidth();
//                LinearLayout.LayoutParams pa=new LinearLayout.LayoutParams(width,width);
//                videoView.setLayoutParams(pa);
                Glide.with(getContext()).load(OKUtilAPI.imgBaseUrl+AppConfig.GOOD_VIDEOIMG).into(videoImage);
                videoView.start(vUrl);
            }else{
                int width=(int)TDevice.getScreenWidth();
                int height=(int)(TDevice.getScreenWidth()/2+150);
                LinearLayout.LayoutParams pa=new LinearLayout.LayoutParams(width,height);
                videoView.setLayoutParams(pa);
                Glide.with(getContext()).load(OKUtilAPI.imgBaseUrl+AppConfig.GOOD_VIDEOIMG).into(videoImage);
                videoView.start(vUrl);
            }
        }

    }

    @Override
    protected int getLayoutId() {
        return R.layout.fragment_xiaoguo;
    }


}
